home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / plenv.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  3KB  |  85 lines

  1. /* Simple interface for defining viewport and window. If "just"=1,  */
  2. /* X and Y scales will be the same, otherwise they are scaled       */
  3. /* independently. The "axis" parameter is interpreted as follows:   */
  4. /* axis=-2 : draw no box, axis or labels                            */
  5. /* axis=-1 : draw box only                                          */
  6. /* axis= 0 : Draw box and label with coordinates                    */
  7. /* axis= 1 : Also draw the coordinate axes                          */
  8. /* axis= 2 : Draw a grid at major tick positions                    */
  9. /* axis=10 : Logarithmic X axis, L!=r Y axis, No X=0 axis         */
  10. /* axis=11 : Logarithmic X axis, L!=r Y axis, X=0 axis            */
  11. /* axis=20 : L!=r X axis, Logarithmic Y axis, No Y=0 axis         */
  12. /* axis=21 : L!=r X axis, Logarithmic Y axis, Y=0 axis            */
  13. /* axis=30 : Logarithmic X and Y axes                               */
  14.  
  15. #include "plplot.h"
  16. #include <math.h>
  17.  
  18. void plenv(xmin,xmax,ymin,ymax,just,axis)
  19. int just,axis;
  20. float xmin, xmax, ymin, ymax;
  21. {
  22.     int level;
  23.     float chrdef, chrht;
  24.     float lb, rb, tb, bb, dx, dy;
  25.     float xsize, ysize, xscale, yscale;
  26.     float spxmin, spxmax, spymin, spymax;
  27.     float vpxmin, vpxmax, vpymin, vpymax;
  28.     float scale;
  29.  
  30.     glev(&level);
  31.     if (level < 1) fatal("Please call PLSTAR before PLENV.");
  32.     
  33.     if (xmin == xmax) fatal("Invalid xmin and xmax arguments in PLENV");
  34.     if (ymin == ymax) fatal("Invalid ymin and ymax arguments in PLENV");
  35.     if ((just != 0) && (just != 1)) fatal("Invalid just option in PLENV");
  36.  
  37.  
  38.     pladv(0);
  39.     if (just == 0)
  40.       plvsta();
  41.     else {
  42.       gchr(&chrdef,&chrht);
  43.       lb = 7.0 * chrht;
  44.       rb = 4.0 * chrht;
  45.       tb = 4.0 * chrht;
  46.       bb = 4.0 * chrht;
  47.       dx = fabs(xmax-xmin);
  48.       dy = fabs(ymax-ymin);
  49.       plgspa(&spxmin,&spxmax,&spymin,&spymax);
  50.       xsize = spxmax - spxmin;
  51.       ysize = spymax - spymin;
  52.       xscale = dx/(xsize - lb - rb);
  53.       yscale = dy/(ysize - tb - bb);
  54.       scale = max(xscale,yscale);
  55.       vpxmin = max(lb,0.5*(xsize - dx/scale));
  56.       vpxmax = vpxmin + (dx/scale);
  57.       vpymin = max(bb,0.5*(ysize - dy/scale));
  58.       vpymax = vpymin + (dy/scale);
  59.       plsvpa(vpxmin,vpxmax,vpymin,vpymax);
  60.     }
  61.     plwind(xmin,xmax,ymin,ymax);
  62.     if (axis == -2)
  63.        ;
  64.     else if (axis == -1)
  65.        plbox("bc",0.0,0,"bc",0.0,0);
  66.     else if (axis == 0) 
  67.        plbox("bcnst",0.0,0,"bcnstv",0.0,0);
  68.     else if (axis == 1) 
  69.        plbox("abcnst",0.0,0,"abcnstv",0.0,0);
  70.     else if (axis == 2) 
  71.        plbox("abcgnst",0.0,0,"abcgnstv",0.0,0);
  72.     else if (axis == 10) 
  73.        plbox("bclnst",0.0,0,"bcnstv",0.0,0);
  74.     else if (axis == 11) 
  75.        plbox("bclnst",0.0,0,"abcnstv",0.0,0);
  76.     else if (axis == 20) 
  77.        plbox("bcnst",0.0,0,"bclnstv",0.0,0);
  78.     else if (axis == 21) 
  79.        plbox("bcnst",0.0,0,"abclnstv",0.0,0);
  80.     else if (axis == 30) 
  81.        plbox("bclnst",0.0,0,"bclnstv",0.0,0);
  82.     else
  83.        fatal("Invalid axis argument in plenv");
  84. }
  85.